class Cat{
    //这些被private修饰的属性和方法只能再当前cat当中使用
    private String name;
    private int age;
    private String color;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public Cat(String name, int age, String color) {
        this.name = name;
        this.age = age;
        this.color = color;
        System.out.println("带三个参数的构造方法");
    }

    public Cat(){
        System.out.println("不带参数的构造方法");
    }

    public void eat(){
        System.out.println(this.name + "正在吃");
    }

    public void bark(){
        System.out.println(this.name + "正在咪咪叫");
    }

    public void sleep(){
        System.out.println(this.name + "正在睡觉");
    }

    /**
     * 打印属性
     */
    public void show(){
        System.out.println("名字 " + this.name + " 年龄 "+ this.age +" 颜色 "+ this.color);
    }

    @Override
    public String toString() {
        return "Cat{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", color='" + color + '\'' +
                '}';
    }
}

public class TestDemo3 {
    public static void main(String[] args) {
        Cat cat3 = new Cat();
        //cat3.name = "xixi";
        cat3.setName("嘻嘻");
        String name = cat3.getName();
        System.out.println(name);
        System.out.println(cat3);
    }

    public static void main2(String[] args) {
        Cat cat3 = new Cat();
        Cat cat = null;
        System.out.println(cat3);
    }
    //类的调用者============
    public static void main1(String[] args) {
        Cat cat1 = new Cat("咪咪",3,"yellow");
        cat1.show();
        cat1.sleep();

        Cat cat2 = new Cat("咪咪2", 2, "橘黄色");
        cat2.show();
        cat2.sleep();

        Cat cat3 = new Cat();
        cat3.sleep();
        cat3.show();
    }
}
